package srdb.migration.schema.metadata;

public class Index extends DBObject {
	private String indexName = null;

	private String indexTableOwner = null;
	private Table parentTable = null;
	private boolean unique = false;
	private ColumnList columns = null;
	private ColumnList refIntColumns = null;
	private String sql;
	private String expression = null;

	public String getExpression() {
		return this.expression;
	}

	public void setExpression(String expression) {
		this.expression = expression;
	}

	public Index() {
	}

	public Index(Table parentTable, String IndexName) {
		this.parentTable = parentTable;
		this.indexName = IndexName;
	}

	public boolean hasExpression() {
		return this.expression != null;
	}

	public void setUniqueness(String Uniqueness) {
		if ((Uniqueness.compareToIgnoreCase("UNIQUE") == 0)
				|| (Uniqueness.compareToIgnoreCase("U") == 0))
			this.unique = true;
		else
			this.unique = false;
	}

	public void setUnique(boolean value) {
		this.unique = value;
	}

	public boolean isUnique() {
		return this.unique;
	}

	public String getName() {
		return this.indexName;
	}

	public void setName(String name) {
		this.indexName = name;
	}

	public String getTableName() {
		return this.parentTable != null ? this.parentTable.getName() : null;
	}

	public void setIndexTableOwner(String indexTableOwner) {
		this.indexTableOwner = indexTableOwner;
	}

	public String getIndexTableOwner() {
		return this.indexTableOwner;
	}

	public String getIndexTargetSchemaName() {
		return this.parentTable.getTargetSchemaName();
	}

	public String getSchemaQualifiedTableName() {
		return getIndexTableOwner() + "." + getTableName();
	}

	public ColumnList getColumns() {
		if (this.columns == null)
			this.columns = new ColumnList();
		return this.columns;
	}

	public void addColumn(Column column) {
		if (this.columns == null) {
			this.columns = new ColumnList();
		}
		this.columns.add(column);
	}

	public DBObject getParent() {
		return this.parentTable;
	}

	public String getSchema() {
		return this.parentTable != null ? this.parentTable.getSchema() : null;
	}

	public String getSql() {
		return this.sql;
	}

	public void setSql(String sql) {
		this.sql = sql;
	}
}

/*

 */